home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 2424 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: mail2news.demon.co.uk!gate.demon.co.uk
  2. From: Jason <tmr@cosine.demon.co.uk>
  3. Newsgroups: comp.sys.cbm
  4. Subject: Re: Commodore Arithmetic (Energy Bars)
  5. Date: Wed, 21 Feb 96 02:14:56 GMT
  6. Organization: Cosine Systems
  7. Message-ID: <9602210214.AA000i3@cosine.demon.co.uk>
  8. References: <100751374@news.acns.nwu.edu> <823986319@p71.f411.n201.z2.ftn> <4g2ld5$i47@barad-dur.nas.com> <4gaoja$8di@gatekeeper2.svl.trw.com>
  9. X-NNTP-Posting-Host: gate.demon.co.uk
  10. X-Newsreader: TIN [AMIGA 1.3 950726BETA PL0]
  11. X-Mail2News-Path: relay-1.mail.demon.net!gate.demon.co.uk
  12.  
  13. Mike Domingo (Mike_Domingo@smtp.svl.trw.com) wrote:
  14. : I've been knocking my brains over creating a simple Energy Bar. My bar 
  15. : is used to display disk drive "blocks free". My "Assembly Programming 
  16. : for the Commodore 64" has examples of simple arithmetic but nothing 
  17. : else. Could someone post an example of an Engergy Bar display routine? 
  18. : I'm most interesting in the arithmetic routines for calculating a 
  19. : percentage of a whole (multiple byte division?) for larger numbers.
  20. : ex. display blocks = (max display blocks / (current blocks free/max 
  21. : blocks free))
  22.  
  23. Right, source code time eh?  This assumes that char 0 is a clear, char 1 has
  24. a 1 pixel line down the left side, char 2 a 2 pixel line and so on till char
  25. 8 which is a solid block...  The label NRG is the present setting.
  26.  
  27.         LDX #$00         This bit just clears the line for the bar.
  28.         LDA #$20
  29. CLRBAR  STA $0400,X
  30.         INX
  31.         CPX #$20
  32.         BNE CLRBAR
  33.  
  34.         LDA NRG          This bit works out how many solid char blocks the
  35.         LSR              bar is going to take and plots them.
  36.         LSR
  37.         LSR
  38.         TAY
  39.         LDX #$00
  40.         LDA #$08
  41. MAINBAR STA $0400,X
  42.         INX
  43.         DEY
  44.         BPL MAINBAR
  45.  
  46.         LDA NRG          Finally, this bit works out the remaining pixels
  47.         AND #$07         and adds them to the end of the bar.
  48.         CLC
  49.         ADC #$01
  50.         DEX
  51.         STA $0400,X
  52.         RTS
  53.  
  54. There, thats a bit slapdash, but it does work and it's flexible enough to
  55. allow you to change the value in NRG very rapidly.  BTW, a value of 0 will
  56. produce a single 1 pixel thin bar.
  57.  
  58. Please note:  this routine is merely for displaying a bar, nothing else.
  59. Simply feed it a value and start it up.
  60.  
  61. Jason  =-)
  62.